var apis = {
	loginer: "http://api.fangchepingtai.com/fangchebbs/admin/loginer",
	// loginer: "http://127.0.0.1:1333/fangchebbs/admin/loginer",
	loginout: "http://api.fangchepingtai.com/fangchebbs/admin/loginout"
};
(function() {
	Path.on("/admin/*", function() {
		// 重新拉取登陆信息
		if (!App.get("admin")) {
			coAjax.post(apis.loginer, function(result) {
				console.log(result)
				if (result) {
					App.set("admin", result);
				};
			}, function(err, errMsg) {
				console.log(errMsg)
				myConfirm("您已退出登陆，请重新登陆", function() {
					Path.jump("/login.html");
				}, function() {
					Path.jump("/main.html");
				});
			});
		};
	});
	// 退出登陆
	App.set("$Event.admin.loginout", function() {
		myConfirm("确定要退出登陆吗？", function() {
			coAjax.post(apis.loginout, function() {
				alert("success", "您已退出登陆");
				Path.jump("/main.html");
			}, function(err, errMsg) {
				console.log(errMsg);
			});
		});
	});
}());